package info.pablo.maven.tulebox.example;

import java.util.Random;

import com.opensymphony.xwork2.ActionSupport;

/**
 * @author pablo_guerrero
 *
 */
public class Names extends ActionSupport{
	private int syllable=0;
	private String race="";
	private String name;
	private String[] orcsNames ={"Ur","og", "ag", "un"};
	private String[] elfsNames ={"il", "al", "el", "in", "ir"};
	
	public String execute()throws Exception{
		if(race!= "Elvish"|| race!="Orcish"){
			return ERROR;
		}
		if(syllable<0){
			return ERROR;
		}
		Random r = new Random();
		if (race.equals("Orcish")){
			for(int i=0;i<syllable;i++){
				name += orcsNames[r.nextInt(orcsNames.length)];
			}
		}else{
			for(int i=0;i<syllable;i++){
				name += elfsNames[r.nextInt(elfsNames.length)];
			}
		}
		
		return SUCCESS;
	}

	/**
	 * @return the syllable
	 */
	public int getSyllable() {
		return syllable;
	}

	/**
	 * @param int the number of syllable to set
	 */
	public void setSyllable(int syllable) {
		this.syllable = syllable;
	}

	/**
	 * @return the race
	 */
	public String getRace() {
		return race;
	}

	/**
	 * @param race the race to set
	 */
	public void setRace(String race) {
		this.race = race;
	}

	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}

	/**
	 * @param name the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}
	
	
	
}
